home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************************
- * *
- * Copyright (c) 1991 Silicon Graphics, Inc. *
- * All Rights Reserved *
- * *
- * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI *
- * *
- * The copyright notice above does not evidence any actual of intended *
- * publication of such source code, and is an unpublished work by Silicon *
- * Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is *
- * the property of Silicon Graphics, Inc. Any use, duplication or *
- * disclosure not specifically authorized by Silicon Graphics is strictly *
- * prohibited. *
- * *
- * RESTRICTED RIGHTS LEGEND: *
- * *
- * Use, duplication or disclosure by the Government is subject to *
- * restrictions as set forth in subdivision (c)(1)(ii) of the Rights in *
- * Technical Data and Computer Software clause at DFARS 52.227-7013, *
- * and/or in similar or successor clauses in the FAR, DOD or NASA FAR *
- * Supplement. Unpublished - rights reserved under the Copyright Laws of *
- * the United States. Contractor is SILICON GRAPHICS, INC., 2011 N. *
- * Shoreline Blvd., Mountain View, CA 94039-7311 *
- **************************************************************************
- *
- * File: sinfo.c
- *
- * Description: Prints detailed information about a STIFF format file.
- * The header and IFD information is printed. For each IFD the tags
- * are printed. Offsets for IFD's and data are also displayed.
- * If a file is not specified on the command-line, stdin is read.
- *
- * Usage: sinfo [STIFF file]
- *
- **************************************************************************/
-
-
- #ident "$Revision: 1.3 $"
-
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <stiff.h>
-
-
- main(int argc, char *argv[])
- {
- STStream *stptr; /* Stream TIFF pointer to read */
- STImageHeader ifd; /* Struct to get image headers */
- int n = 0; /* Number of images read so far */
- unsigned long ifdOffset; /* Maintains offset of next IFD */
- int input; /* input file descriptor */
-
- /*
- * input is from file if a file has been specified on the command
- * line, or standard input if no files were specified.
- */
- input = argc > 1 ? open(argv[1], O_RDONLY) : fileno(stdin);
-
- if (input < 0) {
- perror(argv[0]);
- exit(1);
- }
-
- /*
- * Open a TIFF stream
- */
- if ((stptr = STOpen(input, ST_READ)) == NULL) {
- STPerror(argv[0]);
- exit(1);
- }
-
- /*
- * Print file header information
- */
- (void)printf("TIFF Header (offset: 0)\n");
- (void)printf("First IFD at offset: 0x%04lX\n", stptr->next);
- (void)printf("\n");
-
- /*
- * Read and display IFD information until STReadImageHeader
- * returns -1 indicating that no more IFDs can be read from the
- * stream.
- */
- ifdOffset = stptr->next;
- while (STReadImageHeader(stptr, &ifd) == 0) {
- /*
- * Print the offset of this IFD, which we got out of stptr
- * before calling STReadImageHeader
- */
- n++;
- (void)printf("IFD %d (offset: 0x%04lX)\n", n, ifdOffset);
- /*
- * Now update ifdOffset for next time through the loop.
- */
- ifdOffset = stptr->next;
-
- /*
- * Print the tags
- */
- if (STPrintTags(stdout, stptr) < 0) {
- STPerror(argv[0]);
- exit(1);
- }
-
- /*
- * Print the STIFF Image Header structure
- */
- (void)printf("STIFF Image Header\n");
- (void)printf("\tImage width: %lu\n", ifd.width);
- (void)printf("\tImage height: %lu\n", ifd.height);
- (void)printf("\tBits per sample: %u\n", ifd.bitsPerSample);
- (void)printf("\tSamples per pixel: %u\n", ifd.samplesPerPixel);
- (void)printf("\tImage size (bytes): %lu\n", ifd.imgbytes);
- (void)printf("\tImage type: %u\n", ifd.type);
- (void)printf("\tData format: %u\n", ifd.plane);
- }
-
- /*
- * STReadImageHeader will return -1 with STerrno set to STEEOF to
- * indicate that there are no more images. We don't consider this
- * an error unless no images at all were read in.
- */
- if (STerrno != STEEOF || n == 0) {
- STPerror(argv[0]);
- }
-
- /*
- * Close the TIFF stream
- */
- STClose(stptr);
-
- return 0;
- }
-
-